<?php

defined('IN_IA') or exit('Access Denied');

$mid = $_GPC['mid'];
if(empty($mid)){
    exit('非法访问');
}

$mprice = pdo_fetchcolumn('select price from '. tablename('modules'). 'where mid = :mid',array('mid'=>$mid));
if(empty($mprice)){
    //免费 直接购买成功
    $user_module = array(
        'mid'=>$mid,
        //网站用户的id
        'uid'=>$web_uid = pdo_fetchcolumn('select uid from '.tablename('users').'where openid=:openid',array(':openid'=>$_W['openid'])),
        //免费的截止时间不限
        'deadline'=>-1,
    );
    load()->model("module");
    if(users_module_create($user_module)){
        message("开通成功",url('manage/account'));
    }
}else{
    //跳转到支付页面
    message("节约点，还是不要开通了",url('manage/account'));
}
